<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>扫码报工及异常停机</title>
		<link rel="stylesheet" href="./layui/css/layui.css">
	</head>
	<body>
		<fieldset class="layui-elem-field site-demo-button">
			<legend><big><b>扫码报工及异常停机信息收集</b></big></legend>
			<div class="layui-fluid layui-form layui-form-pane">
				<div class="layui-row layui-form-item">
					<label class="layui-form-label">扫描二维码:</label>
					<div class="layui-input-block">
						<input class="layui-input" placeholder="请扫入特定的二维码" id="qr" type="text"/>
					</div>
				</div>
				<!-- <div class="layui-row"> -->
					<!-- <div class="layui-col-sm1"> -->
						<!-- <label id="JiaBOX" data-JJ="1" data-DQ="DQHS" onclick="JJQK(this)" class="layui-form-label" style="background-color:#5FB878;"><big><b>加盒</b></big></label> -->
					<!-- </div> -->
					<!-- <div class="layui-col-sm1 layui-col-sm-offset1"> -->
						<!-- <label id="JianBOX" data-JJ="-1" data-DQ="DQHS" onclick="JJQK(this)" class="layui-form-label" style="background-color:#FFB800;"><big><b>减盒</b></big></label> -->
					<!-- </div> -->
					<!-- <div class="layui-col-sm1 layui-col-sm-offset1"> -->
						<!-- <label  id="QKBOX" data-JJ="清空" data-DQ="DQHS" onclick="JJQK(this)" class="layui-form-label" style="background-color:#01AAED;"><b>清空盒数量</b></label> -->
					<!-- </div> -->
				<!-- </div> -->
				<!-- <br/> -->
				<!-- <div class="layui-row"> -->
					<!-- <div class="layui-col-sm1"> -->
						<!-- <label id="JiaPCS" data-JJ="1" data-DQ="DQPS" onclick="JJQK(this)" class="layui-form-label" style="background-color:#5FB878;"><big><b>加片</b></big></label> -->
					<!-- </div> -->
					<!-- <div class="layui-col-sm1 layui-col-sm-offset1"> -->
						<!-- <label id="JiaPCS" data-JJ="-1" data-DQ="DQPS" onclick="JJQK(this)" class="layui-form-label" style="background-color:#FFB800;"><big><b>减片</b></big></label> -->
					<!-- </div> -->
					<!-- <div class="layui-col-sm1 layui-col-sm-offset1"> -->
						<!-- <label id="QKPCS" data-JJ="清空" data-DQ="DQPS" onclick="JJQK(this)" class="layui-form-label" style="background-color:#01AAED;"><b>清空片数量</b></label> -->
					<!-- </div> -->
				<!-- </div> -->
			</div>
		</fieldset>
		<fieldset class="layui-elem-field site-demo-button">
			<legend><big><b>这里是当前扫描的信息组合</b></big></legend>
			<div id="DQ" class="layui-fluid layui-form layui-form-pane">
				<div class="layui-col-sm3">
					<label class="layui-form-label">员工工号:</label>
					<div class="layui-input-block">
						<input class="layui-input" readonly=true placeholder="这里是员工工号" id="YGGH" type="text"/>
					</div>
				</div>
				<div class="layui-col-sm3">
					<label class="layui-form-label">员工姓名:</label>
					<div class="layui-input-block">
						<input class="layui-input" readonly=true placeholder="这里是员工姓名" id="YGXM" type="text"/>
					</div>
				</div>
				<div class="layui-row">
					<div class="layui-col-sm3">
						<label class="layui-form-label">当前机台:</label>
						<div class="layui-input-block">
							<input class="layui-input" readonly=true placeholder="这里是当前机台" id="DQJT" type="text"/>
						</div>
					</div>
					<div class="layui-col-sm3">
						<label class="layui-form-label">当前工单:</label>
						<div class="layui-input-block">
							<input class="layui-input" readonly=true placeholder="这里是当前工单" id="DQGD" type="text"/>
						</div>
					</div>
					<div class="layui-col-sm3">
						<label class="layui-form-label">当前盒数:</label>
						<div class="layui-input-block">
							<input class="layui-input" readonly=true placeholder="这里是当前盒数" id="DQHS" type="text"/>
						</div>
					</div>
					<div class="layui-col-sm3">
						<label class="layui-form-label">当前片数:</label>
						<div class="layui-input-block">
							<input class="layui-input" readonly=true placeholder="这里是当前片数" id="DQPS" type="text"/>
						</div>
					</div>
				</div>
			</div>
		</fieldset>
		<fieldset class="layui-elem-field site-demo-button">
			<legend><big><b>自动报工</b></big></legend>
			<div id="BG" class="layui-fluid layui-form layui-form-pane">
			</div>
		</fieldset>
		<fieldset class="layui-elem-field site-demo-button">
			<legend><big><b>异常停机</b></big></legend>
			<div id="YC" class="layui-fluid layui-form layui-form-pane">
			</div>
		</fieldset>
		<script src="./layui/layui.js"></script>
		<script src="./js/jquery.min.js"></script>
		<script src="./js/jquery.qrcode.min.js"></script>
		<script>
			//这里是画面准备完毕后执行的程式
			$(document).ready(function(){
				//载入模块
				layui.use(['layer','form','element'], function(){
					layer.msg('模块载入成功!');
				});
				//扫码输入框选择
				$("#qr").focus();
			});
			//这里开始写入几台对应的站别
			var JT = {
				 "BPA":"固晶"
				,"BPC":"焊线"
				,"BPD":"点胶"
				,"BPI":"分光"
				,"BPJ":"编带"
			}
			//这里开始写入机台故障号码
			var YC = {
				 "EXC22":"日点检保养"
				,"EXC23":"工单切换调机"
				,"EXC24":"更换耗材"
				,"EXC25":"冶具清理"
				,"EXC26":"首件"
				,"EXC27":"生产调机"
				,"EXC11":"设备故障调机"
				,"EXC31":"其他计划外停机"
			}
			//这里开始写入s2的对照表
			var STR2 = {
				 "BP":"DQJT"
				,"EM":"YGGH"
				,"AT":"DQGD"
			}
			var STR3 = {
				 "BOX":"DQHS"
				,"PCS":"DQPS"
				//,"":""
			}
			var sum = 0;
			var Str1 = "0";
			var Str2 = "0";
			/*
			测了半天才发现var要在全局下才能使字典生效,所以不能把字典写在任何包里,ps:之前写在$(document).ready();的包里了
			var jsonString = '{"BP":"DQJT","EM":"YGGH","AT":"DQGD"}';//JSON文本
			var jsObject = JSON.parse(jsonString); //文本转换为json对象
			*/
			//这里是扫描输入框的回车按下后执行的程式
			$("#qr").keypress(function(e){
				if(e.keyCode===13){
					$("#qr").select();
					var QRC = $("#qr").val();
					var s2 = QRC.substr(0,2);
					var s3 = QRC.substr(0,3);
					//如果2字符的字典包含就处理结果
					if(STR2[s2]){
						$("#"+STR2[s2]).val(QRC);
					//否则3字符的字典包含就处理结果
					}else if(STR3[s3]){
						//如果3字符的输入框文本能转成值就转,不能转就是0
						if(parseFloat($("#"+STR3[s3]).val())){
							sum = parseFloat($("#"+STR3[s3]).val());
						}else{
							sum = 0;
						}
						//3字符对应的id值改成求和结果
						$("#"+STR3[s3]).val(sum+1);
					}
				}
			});
			<!-- function JJQK(DQXX){ -->
				<!-- Str1 = DQXX.getAttribute('data-DQ'); -->
				<!-- Str2 = DQXX.getAttribute('data-JJ'); -->
				<!-- if(parseFloat($("#"+Str1).val())){ -->
					<!-- sum = parseFloat($("#"+Str1).val()); -->
				<!-- }else{ -->
					<!-- sum = 0; -->
				<!-- } -->
				<!-- if(parseFloat(Str2)){ -->
					<!-- sum1 = parseFloat(Str2); -->
				<!-- }else{ -->
					<!-- sum1 = -sum; -->
				<!-- } -->
				<!-- $("#"+Str1).val(sum+sum1); -->
				//layer.msg("Str1 = "+Str1+"<br/>Str2 = "+Str2+"<br/>sum = "+sum+"<br/>sum1 = "+sum1+"<br/>选择器 = "+$("#"+Str1).val());
			<!-- } -->
			//当程序的二维码输入框失去焦点后的事件,重新返回焦点
			$("#qr").blur(function(){
				layer.msg('焦点失去了,将重新找回焦点<br/><small><small>ps:此提示会自动消失</small></small>');
				$("#qr").focus();
			});
		</script>
	</body>
</html>